// no_Selected.addEventListener("touchstart",function() {
//     yes_Selected.children[0].src = "./image/rediobtn_nor.png"
//     no_Selected.children[0].src = "./image/rediobtn_sel.png"
// })
// yes_Selected.addEventListener("touchstart",function() {
//     yes_Selected.children[0].src = "./image/rediobtn_sel.png"
//     no_Selected.children[0].src = "./image/rediobtn_nor.png"
// })
//返回箭头
const topPresetBack = document.querySelector(".topPreset a")
topPresetBack.addEventListener("click", function () {
	history.back()
})
const yes_Selected1 = document.querySelector(".wrapper1 .yes")
const no_Selected1 = document.querySelector(".wrapper1 .no")
no_Selected1.addEventListener("touchstart", function () {
	yes_Selected1.children[0].src = "./image/rediobtn_nor.png"
	no_Selected1.children[0].src = "./image/rediobtn_sel.png"
})
yes_Selected1.addEventListener("touchstart", function () {
	yes_Selected1.children[0].src = "./image/rediobtn_sel.png"
	no_Selected1.children[0].src = "./image/rediobtn_nor.png"
})
const yes_Selected2 = document.querySelector(".wrapper2 .yes")
const no_Selected2 = document.querySelector(".wrapper2 .no")
no_Selected2.addEventListener("touchstart", function () {
	yes_Selected2.children[0].src = "./image/rediobtn_nor.png"
	no_Selected2.children[0].src = "./image/rediobtn_sel.png"
})
yes_Selected2.addEventListener("touchstart", function () {
	yes_Selected2.children[0].src = "./image/rediobtn_sel.png"
	no_Selected2.children[0].src = "./image/rediobtn_nor.png"
})
const yes_Selected3 = document.querySelector(".wrapper3 .yes")
const no_Selected3 = document.querySelector(".wrapper3 .no")
no_Selected3.addEventListener("touchstart", function () {
	yes_Selected3.children[0].src = "./image/rediobtn_nor.png"
	no_Selected3.children[0].src = "./image/rediobtn_sel.png"
})
yes_Selected3.addEventListener("touchstart", function () {
	yes_Selected3.children[0].src = "./image/rediobtn_sel.png"
	no_Selected3.children[0].src = "./image/rediobtn_nor.png"
})
//   异常时间事件
const abnormal = document.querySelector(".time .back span")
// 获取时间
$("#kinerDatePickerInput1").kinerDatePicker({
	clickMaskHide: true,
	showHandler: function (ctx) {
		// console.log("显示时间选择器:", ctx);
	},
	hideHandler: function (ctx) {
		// console.log("隐藏时间选择器:", ctx);
	},
	changeHandler: function (vals, ctx) {
		// console.log("时间改变:", vals, ctx);
	},
	okHandler: function (vals, ctx) {
		// console.log("确定选择:", vals, ctx);
	},
	cancelHandler: function (ctx) {
		// console.log("取消选择:", ctx);
	}
})
$("#btn1").click(function () {
	// console.log($("#kinerDatePickerInput1").kinerDatePickerVal());
})
$("#kinerDatePickerInput2").kinerDatePicker({
	clickMaskHide: true,
	showHandler: function (ctx) {
		// console.log("显示时间选择器:", ctx);
	},
	hideHandler: function (ctx) {
		// console.log("隐藏时间选择器:", ctx);
	},
	changeHandler: function (vals, ctx) {
		// console.log("时间改变:", vals, ctx);
	},
	okHandler: function (vals, ctx) {
		// console.log("确定选择:", vals, ctx);
	},
	cancelHandler: function (ctx) {
		// console.log("取消选择:", ctx);
	}
})

$("#btn2").click(function () {
	// console.log($("#kinerDatePickerInput2").kinerDatePickerVal());
})
// 绑定时间点击事件
const abnormalTimes = document.querySelector(".time .back span ")
const contentTime = document.querySelector(".time .abnormalTime .cotent")
// 时间值
const kinerDatePickerInput = document.querySelector(
	".time .abnormalTime .kinerDatePickerInput"
)
const btnCancel = document.querySelector(".time .abnormalTime .Cancel")
const btnconfirm = document.querySelector(".time .abnormalTime .confirm")
let flagTime = false
let flagscroll = false
//获取时间
let datatime = ""

abnormalTimes.addEventListener("click", function () {
	flagTime = true
	if (flagTime) {
		flagscroll = true
		abnormalTimes.style.opacity = "0"
		contentTime.style.display = "block"
	}
})

// 点击取消选择
btnCancel.addEventListener("click", function () {
	if (flagTime) {
		flagscroll = false
		kinerDatePickerInput.innerText = "请选择时间"
		abnormalTimes.style.opacity = "1"
		contentTime.style.display = "nwrapper1"
	}
})
const dataAbn = { times: "", address: "", type: "", datail: "" }
// 点击确认选择
btnconfirm.addEventListener("click", function () {
	datatime = kinerDatePickerInput.innerText + "  13:00"
	abnormalTimes.style.opacity = "1"
	contentTime.style.display = "nwrapper1"
	abnormalTimes.innerText = datatime
	dataAbn.times = datatime
})
dataAbn.address = "浙江省 杭州市 钱塘区"
//监视页面滑动
const content1 = document.querySelector(".content1")
window.addEventListener("scroll", function () {
	const top = this.document.documentElement.scrollTop
	// console.log(top);
	if (flagscroll) {
		if (top > content1.offsetTop) {
			abnormalTimes.style.opacity = "1"
			contentTime.style.display = "nwrapper1"
		} else {
			abnormalTimes.style.opacity = "0"
			contentTime.style.display = "block"
		}
	} else return
})

//添加点击事件
const li1 = document.querySelectorAll(".type ul li ")
const li2 = document.querySelectorAll(".fine ul li ")
const li3 = document.querySelectorAll(".deduction ul li ")
const li4 = document.querySelectorAll(".fault_type ul li ")
for (let i = 0; i < li1.length; i++) {
	let li_1 = li1[i]
	li_1.addEventListener("touchstart", function () {
		const active = document.querySelector(".active")
		active && active.classList.remove("active")
		li_1.classList.add("active")
	})
}
for (let i = 0; i < li2.length; i++) {
	let li_2 = li2[i]
	li_2.addEventListener("touchstart", function () {
		const active = document.querySelector(".active")
		active && active.classList.remove("active")
		li_2.classList.add("active")
	})
}
for (let i = 0; i < li3.length; i++) {
	let li_3 = li3[i]
	li_3.addEventListener("touchstart", function () {
		const active = document.querySelector(".active")
		active && active.classList.remove("active")
		li_3.classList.add("active")
	})
}

for (let i = 0; i < li4.length; i++) {
	let li_4 = li4[i]
}
/* li_4.addEventListener("touchstart", function () {
	const active = document.querySelector(".active")
	active && active.classList.remove("active")
	li_4.classList.add("active")
}) */
const index = new URLSearchParams(location.search).get("id") || 0
const taskInfo = JSON.parse(localStorage.getItem("deliveryInfo"))
aaaaaa.addEventListener("touchstart", function () {
	// 修改数据
	taskInfo[index].Status = 2
	taskInfo[index].isDeliver = false
	// 修改数据后上传到本地
	localStorage.setItem("deliveryInfo", JSON.stringify(taskInfo))
	location.href = "../module04/mainFunctionPage.html"
})
